package DataMining;

import java.lang.reflect.Array;
import java.util.ArrayList;
import java.util.Iterator;

//p59-61
public final class NumericDataSets {
	public static Double[][] BasicTestArray = {{2.0,2.0},{1.0,1.0},{3.0,3.0},{50.0,50.0}};
	public static Double[][] XYArray1 = {{6.0,4.0},{2.0,9.0},{6.0,3.0},{5.0,7.0},{6.0,1.0},{2.0,8.0},{1.0,3.0},{2.0,5.0},{4.0,6.0},{2.0,5.0}};
	public static Double[][] XYArray2 = {{6.1,6.4},{5.2,6.1},{3.6,6.3},{1.5,6.3},{1.6,6.1},{2.2,5.8},{4.1,6.3},{3.2,6.5},{3.4,6.1},{1.2,5.5},{3.5,5.6},{3.6,6.4},{2.1,5.6},{6.5,5.5},{3.5,6.4},{2.1,6.3},{3.3,5.6},{1.4,6.4},{6.5,6.3},{4.6,5.5},{3.3,6.3},{6.1,5.5},{3.6,6.2}};
	public static Double[][] XYArray3 = {{6.5,1.4},{7.4,2.9},{9.2,0.9},{4.8,1.7},{5.2,2.5},{6.0,2.3},{5.6,3.4},{9.2,8.1},{0.4,1.1},{6.5,2.9},{7.4,0.3},{7.6,6.2},{3.3,0.6},{4.6,2.5},{7.2,3.6},{9.9,9.1},{8.2,1.8},{8.0,2.6},{6.9,0.9},{7.5,1.9}};
	
	public static Double[][] ReturnAllArrays()
	{
		return AppendTwoDimensionalArrays();
	}
	
	private static Double[][] AppendTwoDimensionalArrays()
	{
		ArrayList<Double[][]> arrays = new ArrayList<Double[][]>();
		arrays.add(BasicTestArray);
		arrays.add(XYArray1);
		arrays.add(XYArray2);
		arrays.add(XYArray3);
		
		int length = 0;
		for (Double[][] ar : arrays)
		{
			length += ar.length;
		}
		
		Double[][] results = new Double[length][];
		int offset = 0;
		Iterator<Double[][]> it = arrays.iterator();
		
		for (int j = 0; j < arrays.size(); j++)
		{
			Double[][] table = it.next();
			for (int i = 0; i < table.length; i++)
			{
				results[offset+i] = (Double[]) Array.newInstance(Double.class, table[i].length);
				for(int k = 0; k < table[i].length; k++)
				{
					results[offset+i][k] = table[i][k];
				}
			}
			offset += table.length;
		}
		
		return results;
	}
}
